# Maintainer: J. Peter Mugaas <jpmugaas@suddenlink.net>

_realname=backports.ssl_match_hostname
pkgbase=mingw-w64-python2-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python2-${_realname}")
pkgver=3.7.0.1
pkgrel=1
pkgdesc="The ssl.match_hostname() function from Python 3.5 (mingw-w64)"
arch=('any')
url='https://pypi.python.org/pypi/backports.ssl_match_hostname'
license=('PSF')
makedepends=("${MINGW_PACKAGE_PREFIX}-python2"
             "${MINGW_PACKAGE_PREFIX}-python2-setuptools")
depends=("${MINGW_PACKAGE_PREFIX}-python2-backports")
optdepends=("${MINGW_PACKAGE_PREFIX}-python2-ipaddress: for IPAddress ServerAltnames support")
options=('staticlibs' 'strip' '!debug')
source=("https://pypi.python.org/packages/source/b/backports.ssl_match_hostname/backports.ssl_match_hostname-$pkgver.tar.gz")
sha256sums=('bb82e60f9fbf4c080eabd957c39f0641f0fc247d9a16e31e26d594d8f42b9fd2')

prepare() {
  cd "${srcdir}"
  rm backports.ssl_match_hostname-$pkgver/backports/__init__.py
  rm -rf python2-build-${CARCH} | true
  cp -r "${_realname}-${pkgver}" "python2-build-${CARCH}"
  # Set version for setuptools_scm
  export SETUPTOOLS_SCM_PRETEND_VERSION=$pkgver
}

build() {
  msg "Python 2 build for ${CARCH}"  
  cd "${srcdir}/python2-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python2 setup.py build
}

package() {
  cd "${srcdir}/python2-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python2 setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1 --skip-build
}
